import Vue from 'vue'

let status={
  modalImage: {
    isShow: false,
    isLoading: false,
  }
}

let page = {
  total: 1,
  startIndex: 0,
  stepNumber: 60,
  currentPage: 1
};

let data = {
  colorList: [],
  categoryList: []
};

let params = {
  selectedClassification:"",
  classificationLevel:0,
  state:'',
  productCode:""
};

let  tableTitles=function (self) {
  var titles =  [
    {
      title: '#',
      type: 'index',
      width: 80,
      align: 'center'
    },
    {
      title: 'SKU',
      key: 'productCode',
      minWidth: 100,
      align: 'center',
      render: (h, params) => {
        var productUrl = Vue.prototype.$tiyProductUrl(params.row.productCode);
        return h('div',[h('a',{
          attrs:{href:productUrl,target:'_blank'}
        },params.row.productCode)]);
      }
    },
    {
      title: '色卡名称',
      key: 'colorName',
      minWidth: 100,
      align: 'center'
    },
    {
      title: '尺码',
      key: 'sizeName',
      minWidth: 100,
      align: 'center'
    },
    {
      title: '色卡图片',
      key: 'colorImg',
      minWidth: 100,
      render: (h, params) => {
        let yunPath = Vue.prototype.$store.getters.imgPrefix;
        let imageUrl = Vue.prototype.$store.getters.imgPrefix + params.row.colorImg;
        return  h('img', {
          attrs: {src: imageUrl, height: 60},
          on: {
            click: () => {
              status.modalImage.url = imageUrl;
              status.modalImage.isShow = true;
            }
          }
        })
      },
      align: 'center'
    },
   {
    title: '色卡状态',
      key: 'state',
      width: 120,
      render: (h, params) => {
      let state = '';
      if (params.row.colorState === 100) {
        state = '已上架';
      } else if (params.row.colorState === 200) {
        state = '已下架';
      } else {
        state = '回收站';
      }
      // return h('div',state);


        let isUp = params.row.colorState === 100;
        return (
          <div>
            <tag color={!isUp?'magenta':'green'}>{state}</tag>
          </div>
        );



    },
      align: 'center'
  },

   !self.$authority('PRODUCT-1-210')?null: {
      title: '操作',
      key: 'action',
      align: 'center',
     minWidth: 100,
      render: (h, params) => {
        return h('div', [
          h('Button', {
            props: {type: 'primary', size: 'small', icon: "edit",},
            style: {marginRight: '10px',display: params.row.state == 300 ? 'none':''},
            on: {
              click: () => {
                self.editItem(params.index);
              }
            }
          }, '编辑'),
          ]
        )

      },

    }
  ]

  return self.$authTableTitles(titles)
};

export  default  {
  tPage: page,
  tParam: params,
  // addModal:addModal,
  tData: data,
  listTableTitles:tableTitles,
  tStatus:status
};
